package com.framework.base.annontation;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;

/**
 * @author chaolong.jin
 * @description
 * @date 2019/08/09 15:37
 */
public class Main {
    private String a;

    public static void main(String[] args) {
        try {
            Class c = Class.forName("com.framework.base.annontation.Main");
            Main m = (Main) c.newInstance();
            Constructor[] constructors= c.getConstructors();
           Object O= constructors[0].newInstance(null);
            List<Field> fieldList = Arrays.asList(c.getDeclaredFields());
            for (Field field : fieldList) {
                field.set(m, "123");
            }

            System.out.println(m.a);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
